package br.com.ps.bombertournament.game.action;

import br.com.ps.bombertournament.game.BaseAction;
import br.com.ps.bombertournament.game.BaseGameObject;
import br.com.ps.bombertournament.game.WrapperMap;

/**
 * Resize the game object with new values
 * 
 * @author Rennan Stefan Boni - rennanboni@gmail.com
 */
public class ResizeAction extends BaseAction {

	private static final String WIDTH_PROPERTY = "width";
	private static final String HEIGHT_PROPERTY = "height";
	
	@Override
	public void create() {
		// DO nothing
	
	}

	@Override
	public void execute(BaseGameObject owner) {
		WrapperMap parameters = super.getParameters();
		
		float width = owner.getWidth();
		float height = owner.getHeight();
		if (parameters.containsKey(WIDTH_PROPERTY)) {
			width = parameters.getFloat(WIDTH_PROPERTY);
		}
		if (parameters.containsKey(HEIGHT_PROPERTY)) {
			height = parameters.getFloat(HEIGHT_PROPERTY);
		}
		
		owner.setBounds(owner.getX(), owner.getY(), width, height);
		
		super.setExecuted(true);
	}
	
	@Override
	public void undo(BaseGameObject owner) {
		// Do nothing
	}
}
